package BOOK;

public class Booklist {
    //int[] Book = new int[];对比发现，下列语句指的是一个属于Book类的books数组
    private Book[] books = new Book[10];
    private int usedSize;//记录当前books数组当中有多少本书

    public Booklist(){
        books[0] = new Book("三国演义","罗贯中",89,"小说");
        books[1] = new Book("西游记","吴承恩",78,"小说");
        books[2] = new Book("红楼梦","曹雪芹",49,"小说");
        this.usedSize = 3;
    }

    //对封装起来的books数组提供操作方法
    public Book getBook(int pos){
        return this.books[pos];
    }

    public void setBook(Book book){
        this.books[usedSize] = book;
    }

    public void setBook(int pos,Book book){
        this.books[pos] = book;
    }

    // 系统自动生成的方法（getter and setter）不符合我们的需求：在书架上指定位置放入指定的书
    public void setBooks(int pos,Book book){
        books[pos] = book;
    }
    public int getUsedSize() {
        return usedSize;
    }

    public void setUsedSize(int usedSize) {
        this.usedSize = usedSize;
    }
}
